add RSpecs for regex replace

HyShai 9 anni fa
parent
commit
728c7c73a8
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      spec/concerns/liquid_interpolatable_spec.rb

+ 13 - 0
spec/concerns/liquid_interpolatable_spec.rb

@@ -165,5 +165,18 @@ describe LiquidInterpolatable::Filters do
165 165
         expect(@agent.interpolated['long_url']).to eq('http://2many.x/6')
166 166
       end
167 167
     end
168
+    
169
+    describe 'regex_replace' do
170
+      it 'should replace all occurences of a string using regex' do
171
+        expect(@filter.regex_replace('foobar foobar', /\S+bar/, 'foobaz')).to eq('foobaz foobaz')
172
+      end
173
+    end
174
+
175
+    describe 'regex_replace_first' do
176
+      it 'should replace the first occurences of a string using regex' do
177
+        expect(@filter.regex_replace_first('foobar foobar', /\S+bar/, 'foobaz')).to eq('foobaz foobar')
178
+      end
179
+    end
180
+    
168 181
   end
169 182
 end